package com.tencent.wxcloudrun.controller;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.manager.StoreManager;
import com.tencent.wxcloudrun.vo.request.store.*;
import com.tencent.wxcloudrun.vo.response.store.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author ZhaoZiYin
 * @Date 2025/2/20
 * @Description 商家控制器
 */
@Api(tags = "商家控制器")
@Slf4j
@RestController
@Validated
@RequestMapping("/api/store")
public class StoreController {

    @Resource
    private StoreManager storeManager;

    @ApiOperation("新增商品分类")
    @PostMapping(value = "/prodType/add")
    public ApiResponse<StoreProdTypeAddResVo> addProdType(@RequestBody @Valid StoreProdTypeAddReqVo reqVo) {
        return ApiResponse.ok(storeManager.addProdType(reqVo));
    }

    @ApiOperation("删除商品分类")
    @PostMapping(value = "/prodType/delete")
    public ApiResponse<StoreProdTypeDeleteResVo> deleteProdType(@RequestBody @Valid StoreProdTypeDeleteReqVo reqVo) {
        return ApiResponse.ok(storeManager.deleteProdType(reqVo));
    }

    @ApiOperation("查询商品分类")
    @PostMapping(value = "/prodType/list")
    public ApiResponse<StoreProdTypeListResVo> listProdType(@RequestBody @Valid StoreProdTypeListReqVo reqVo) {
        return ApiResponse.ok(storeManager.listProdType(reqVo));
    }

    @ApiOperation("新增商品")
    @PostMapping(value = "/prod/add")
    public ApiResponse<StoreProdAddResVo> addProd(@RequestBody @Valid StoreProdAddReqVo reqVo) {
        return ApiResponse.ok(storeManager.addProd(reqVo));
    }

    @ApiOperation("更新商品")
    @PostMapping(value = "/prod/update")
    public ApiResponse<StoreProdUpdateResVo> updateProd(@RequestBody @Valid StoreProdUpdateReqVo reqVo) {
        return ApiResponse.ok(storeManager.updateProd(reqVo));
    }

    @ApiOperation("上架商品")
    @PostMapping(value = "/prod/putOn")
    public ApiResponse<StoreProdPutOnResVo> putOnProd(@RequestBody @Valid StoreProdPutOnReqVo reqVo) {
        return ApiResponse.ok(storeManager.putOnProd(reqVo));
    }

    @ApiOperation("下架商品")
    @PostMapping(value = "/prod/takeOff")
    public ApiResponse<StoreProdTakeOffResVo> takeOffProd(@RequestBody @Valid StoreProdTakeOffReqVo reqVo) {
        return ApiResponse.ok(storeManager.takeOffProd(reqVo));
    }

    @ApiOperation("删除商品")
    @PostMapping(value = "/prod/delete")
    public ApiResponse<StoreProdDeleteResVo> deleteProd(@RequestBody @Valid StoreProdDeleteReqVo reqVo) {
        return ApiResponse.ok(storeManager.deleteProd(reqVo));
    }

    @ApiOperation("查询商品详情")
    @PostMapping(value = "/prod/query")
    public ApiResponse<StoreProdQueryResVo> queryProd(@RequestBody @Valid StoreProdQueryReqVo reqVo) {
        return ApiResponse.ok(storeManager.queryProd(reqVo));
    }

    @ApiOperation("查询商品列表")
    @PostMapping(value = "/prod/list")
    public ApiResponse<StoreProdListResVo> listProd(@RequestBody @Valid StoreProdListReqVo reqVo) {
        return ApiResponse.ok(storeManager.listProd(reqVo));
    }

}
